// 导入常量的actionTypes
import { actionTypes } from "./index";

import { fromJS } from 'immutable'
// 被fromJS包裹后的对象是不可变更的
const defaultState = fromJS({
  isFocus: false
})
// 创建一个reducer，用于返回新的状态，利于action的修改
const reducer = (state = defaultState, action) => {
  if (action.type === actionTypes.HANDLE_FOCUS) {
    return state.set('isFocus', true)
  } else if (action.type === actionTypes.HANDLE_BLUR) {
    return state.set('isFocus', false)
  }
  return state
}

export default reducer